package fictional.Common;

import java.util.*;

/**
 * The interface for the DB access layer 
 */
public interface IDAL {
	final int OPERATION_FAILED = -1; 
	
	/**
	 * Gets all gender items
	 * @param response The response
	 * @return A list with all genders in DB
	 */
	List<GenderItem> getAllGenders(Response response);
	/**
	 * Gets all organizations from the DB
	 * @param response The response
	 * @return A list with all organizations in DB
	 */
	List<OrganizationItem> getAllOrganizations(Response response);
	/**
	 * Gets all places from the DB
	 * @param response The response
	 * @return A list with all places in DB
	 */
	List<PlaceItem> getAllPlaces(Response response);
	/**
	 * Gets all powers from the DB
	 * @param response The response
	 * @return A list with all powers in DB
	 */
	List<PowerItem> getAllPowers(Response response);
	/**
	 * Gets all species from the DB
	 * @param response The response
	 * @return A list with all species in DB
	 */
	List<SpeciesItem> getAllSpecies(Response response);
	/**
	 * Gets all occupations from the DB
	 * @param response The response
	 * @return A list with all occupations in DB
	 */
	List<OccupationItem> getAllOccupations(Response response);	
	/**
	 * Gets a short character item by its name. Used for characters search
	 * @param name The name
	 * @param response The response
	 * @return The list with all search results
	 */
	ArrayList<ShortCharacterItem> getShortCharacterByName(String name,Response response);
	/**
	 * Gets the corresponds character element
	 * @param char_id The character's id
	 * @param response The response
	 * @return The character
	 */
	CharacterItem getCharacterById(int char_id,Response response);
	/**
	 * Gets a ShortCharacterItem by its id
	 * @param char_id The id
	 * @param response The response
	 * @return The ShortCharacterItem
	 */
	ShortCharacterItem getShortCharacterById(int char_id, Response response);
	/**
	 * Gets the default character associated with this user
	 * @param user_id The user id
	 * @param response The response
	 * @return The character
	 */
	CharacterItem getDefaultCharacter(int user_id,Response response);
	/**
	 * Checks if this user allows editing this character
	 * @param char_id The char id
	 * @param user_id The user id
	 * @param response The response
	 * @return True iff this user allowed editing this character, false otherwise
	 */
	boolean isAllowedEditingCharacter(int char_id,int user_id,Response response);
	/**
	 * Edits a character's status line
	 * @param status The new status line
	 * @param char_id The character id
	 * @param response The response
	 */
	void editStatus(String status,int char_id,Response response);
	/**
	 * Translates the user/password to the inner userID.
	 * @param username The username
	 * @param password The password
	 * @param response The response
	 * @return the user id, or -1 if login/password combination does not match the records
	 */
	int login(String username,String password,Response response);	
	/**
	 * Aborts a friendship on the database
	 * @param char_id The character
	 * @param friend_id The friend
	 * @param response The response
	 */
	void deleteFriend(int char_id, int friend_id, Response response);
	/**
	 * Gets the wall of the supplied CharacterItem instance
	 * @param character The character
	 * @param response The response
	 * @return The corresponds character's wall
	 */
	Wall getWall(CharacterItem character, Response response);
	/**
	 * Posts a WallItem into the database
	 * @param wallItem The WallItem instance to post
	 * @param response The response
	 * @return The new ID of the posted WallPost, or OPERATION_FAILED if failed
	 */
	int postToWall(WallItem wallItem, Response response);
	/**
	 * Removes a wall post from the database
	 * @param wallPost The wall post
	 * @param response The response
	 */
	void deleteWallPost(WallItem wallPost, Response response);
	/**
	 * Gets the private message board of the supplied character id
	 * @param character The character
	 * @param response The response
	 * @return The corresponds character's private message board
	 */
	Messages getMessages(CharacterItem character, boolean getReceived, Response response);
	/**
	 * Posts a MessageItem into the database 
	 * @param message The MessageItem instance to post
	 * @param response The response
	 * @return The new ID of the posted MessageItem, or OPERATION_FAILED if failed
	 */
	int sendMessage(MessageItem message, Response response);
	/**
	 * Removes a private message from the database
	 * @param message The message
	 * @param response The response
	 */
	void deleteMessage(int message_id, Response response);
	/**
	 * Marks a message as read one  
	 * @param message The message
	 * @param response The response
	 */
	void readMessage(int message_id, Response response);
	/**
	 * Gets the friend requests from the database
	 * @param character The character which receives the requests
	 * @param response The response
	 * @return All friend requests, sorted by date (newer first)
	 */
	FriendRequests getFriendRequests(CharacterItem character, boolean getReceived, Response response);
	/**
	 * Creates a friend request in the database
	 * @param request The request
	 * @param response The Response
	 * @return The new ID of the posted friend request, or OPERATION_FAILED
	 */
	int sendFriendRequest(FriendRequestItem request, Response response);
	/**
	 * Deletes a friend request from the database
	 * @param request The request
	 * @param response The response
	 */
	void deleteFriendRequest(FriendRequestItem request, Response response);
	/**
	 * Adds a friendship into the database
	 * @param request The friendship request, containing the two new friends
	 * @param response The response
	 */
	void addFriendship(int char_a_id, int char_b_id, Response response);
	/**
	 * Sets a profile image for the supplied character 
	 * @param img The image
	 * @param character The character 
	 * @param response The response
	 */
	void setProfileImage(ImageItem img,CharacterItem character,Response response);
	/**
	 * Deletes the supplied image from the DB
	 * @param img The image
	 * @param response The response
	 */
	void deleteCharacterImage(ImageItem img,Response response);
	/**
	 * Gets similar characters to the supplied character
	 * @param char_id The character id
	 * @param response The response
	 * @return The results list
	 */
	ArrayList<ShortCharacterItem> getSimilarCharacters(int char_id, Response response);
	/**
	 * Gets relative characters to the supplied character
	 * @param char_id The character id
	 * @param response The response
	 * @return The results list
	 */
	ArrayList<ShortCharacterItem> getUnfriendedRelatives(int char_id, Response response);
	/**
	 * Inserts a new poke into the DB
	 * @param poke The poke
	 * @param response The response
	 */
	void insertPoke(PokeItem poke,Response response);
	/**
	 * Gets all pokes connected with this character 
	 * @param character The character 
	 * @param response The response
	 * @return The new Pokes element
	 */
	Pokes getPokes(CharacterItem character, Response response);	
	/**
	 * Inserts a new user into the DB
	 * @param user The user
	 * @param response The response
	 * @return The new user id, or OPERATION_FAILED if failed 
	 */
	int insertUser(User user,Response response);
	/**
	 * Inserts a new character into the db 
	 * @param userId The character's creator user
	 * @param charName The character's name
	 * @param response The response
	 * @return The new character id, or OPERATION_FAILED if failed
	 */
	int insertCharacter(int userId, String charName, Response response);
	/**
	 * Inserts a new occupation item into the DB
	 * @param occupation The occupation
	 * @param response The response
	 * @return The full data OccupationItem
	 */
	OccupationItem insertOccupation(String occupation,Response response);
	/**
	 * Inserts a new organization item into the DB
	 * @param organization The organization 
	 * @param response The response
	 * @return The full data OrganizationItem
	 */
	OrganizationItem insertOrganization(String organization,Response response);
	/**
	 * Inserts a new power item into the DB
	 * @param power The power 
	 * @param response The response
	 * @return The full data PowerItem
	 */	
	PowerItem insertPower(String power,Response response);
	/**
	 * Inserts a new image onto this character 
	 * @param character The character 
	 * @param imageLink The image link
	 * @param response The response
	 * @return The new image ID, or OPERATION_FAILED if failed
	 */
	int insertCharacterImage(CharacterItem character, String imageLink, Response response);
	/**
	 * Updates the character following details: GenderItem, SpeciesItem, PlaceItem 
	 * @param character The character
	 * @param response The response
	 */
	void updateCharacterDetails(CharacterItem character,Response response);
	/**
	 * Updates the following occupations into the supplied character
	 * @param ci The character
	 * @param occupations The occupations
	 * @param response The response
	 */
	void updateOccupations(CharacterItem ci, List<OccupationItem> occupations, Response response);
	/**
	 * Updates the following organizations into the supplied character
	 * @param ci The character 
	 * @param organizations The organizations
	 * @param response The response
	 */
	void updateOrganizations(CharacterItem ci, List<OrganizationItem> organizations, Response response);
	/**
	 * Updates the following powers into the supplied character
	 * @param ci The character 
	 * @param powers The powers
	 * @param response The response
	 */
	void updatePowers(CharacterItem ci, List<PowerItem> powers, Response response);
}
